package gaej.example.contact.client;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class DirigentDelegate {
    private MusicServiceAsync musicService = GWT.create(MusicService.class);
    DirigentGUI gui;
    
    void listDirigenten() {
        musicService.listDirigenten(new AsyncCallback<List<Dirigent>> () {
                    public void onFailure(Throwable caught) {
                        gui.service_eventListDirigentenFailed(caught);
                    }
        
                    public void onSuccess(List<Dirigent> result) {
                        gui.service_eventListRetrievedFromService(result);
                        
                    }
        }//end of inner class
        );//end of listDirigents method call.
    }
    
    void addDirigent(final Dirigent dirigent) {
        musicService.addDirigent(dirigent, new AsyncCallback<Void> () {
            public void onFailure(Throwable caught) {
                gui.service_eventAddDirigentFailed(caught);
            }

            public void onSuccess(Void result) {
                gui.service_eventAddDirigentSuccessful();
            }
        }//end of inner class
        );//end of addDirigent method call.        
    }

    void updateDirigent(final Dirigent dirigent) {
        musicService.updateDirigent(dirigent, new AsyncCallback<Void> () {
            public void onFailure(Throwable caught) {
                gui.service_eventUpdateDirigentFailed(caught);
            }

            public void onSuccess(Void result) {
                gui.service_eventUpdateSuccessful();
            }
        }//end of inner class
        );//end of updateDirigent method call.        
    }

    void removeDirigent(final Dirigent dirigent) {
        musicService.removeDirigent(dirigent, new AsyncCallback<Void> () {
            public void onFailure(Throwable caught) {
                gui.service_eventRemoveDirigentFailed(caught);
            }

            public void onSuccess(Void result) {
                gui.service_eventRemoveDirigentSuccessful();
            }
        }//end of inner class
        );//end of updateDirigent method call.        
    }
    
}
